/*
 * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION!

import { int32, float32 } from "@koalaui/common"
import { KStringPtr, KBoolean, RuntimeType, runtimeType, isResource, isInstanceOf } from "@koalaui/interop"
import { NodeAttach, remember } from "@koalaui/runtime"
import { ComponentBase } from "./ComponentBase"
import { TypeChecker } from "#components"
import { ArkCommonMethodComponent } from "./ArkCommon"
import { ArkNavigatorPeer } from "./peers/ArkNavigatorPeer"
import { CommonMethod } from "./ArkCommonInterfaces"
import { NavigatorAttribute, NavigationType } from "./ArkNavigatorInterfaces"
import { Literal_String_target_NavigationType_type } from "./SyntheticDeclarations"
/** @memo:stable */
export class ArkNavigatorComponent extends ArkCommonMethodComponent {
    getPeer(): ArkNavigatorPeer {
        return (this.peer as ArkNavigatorPeer)
    }
    /** @memo */
    public setNavigatorOptions(value?: Literal_String_target_NavigationType_type): this {
        if (this.checkPriority("setNavigatorOptions")) {
            const value_type = runtimeType(value)
            if ((((RuntimeType.UNDEFINED == value_type)))) {
                this.getPeer()?.setNavigatorOptions1Attribute()
                return this
            }
            if ((((RuntimeType.OBJECT == value_type)) || ((RuntimeType.UNDEFINED == value_type)))) {
                const value_casted = value as (Literal_String_target_NavigationType_type | undefined)
                this.getPeer()?.setNavigatorOptions0Attribute(value_casted)
                return this
            }
            throw new Error("Can not select appropriate overload")
        }
        return this
    }
    /** @memo */
    public active(value: boolean): this {
        if (this.checkPriority("active")) {
            const value_casted = value as (boolean)
            this.getPeer()?.activeAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public type(value: NavigationType): this {
        if (this.checkPriority("type")) {
            const value_casted = value as (NavigationType)
            this.getPeer()?.typeAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public target(value: string): this {
        if (this.checkPriority("target")) {
            const value_casted = value as (string)
            this.getPeer()?.targetAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public params(value: Object): this {
        if (this.checkPriority("params")) {
            const value_casted = value as (Object)
            this.getPeer()?.paramsAttribute(value_casted)
            return this
        }
        return this
    }
    public applyAttributesFinish(): void {
        // we calls this function outside of class, so need to make it public
        super.applyAttributesFinish()
    }
}

/** @memo */
export function ArkNavigator(
  /** @memo */
  style: ((attributes: ArkNavigatorComponent) => void) | undefined,
  /** @memo */
  content_: (() => void) | undefined,
  value?: Literal_String_target_NavigationType_type | undefined
) {
    const receiver = remember(() => {
        return new ArkNavigatorComponent()
    })
    NodeAttach<ArkNavigatorPeer>((): ArkNavigatorPeer => ArkNavigatorPeer.create(receiver), (_: ArkNavigatorPeer) => {
        receiver.setNavigatorOptions(value)
        style?.(receiver)
        content_?.()
        receiver.applyAttributesFinish()
    })
}
